package com.mes.cotask.domain;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Id;

import org.hibernate.annotations.GenericGenerator;

import com.mes.common.domain.BasicModel;
import com.mes.task.domain.Task;

/**
 * 协作任务 entity.
 */

public class Cotask extends BasicModel {
	
	// Fields
	private static final long serialVersionUID = 7236921288788708899L;
	
	public final static long COTASK_STATE_PLANED = 0; // 已计划
	public final static long COTASK_STATE_SENDED = 1; // 已送出
	public final static long COTASK_STATE_RECEIVED = 2; // 已接收
	public final static long COTASK_STATE_FINISHED = 3; // 已完工
	public final static long COTASK_STATE_FETCHED = 4; // 已取走
	public final static long COTASK_STATE_DELIVERIED = 5; // 已入库
	public final static long COTASK_STATE_CANCELED = 8; // 已计划
	
	//consult state 
	public static final long STATE_FINALIZE    = 5;
	public static final long STATE_AGREE       = 6;
	public static final long STATE_TO_SENDER   = 7;
	public static final long STATE_TO_RECEIVER = 8;
	public static final long STATE_TO_CHIEF	  = 9;
	
	//consult operation
	public static final int OP_FINALIZE    = 505;
	public static final int OP_AGREE       = 506;
	public static final int OP_TO_SENDER   = 507;
	public static final int OP_TO_RECEIVER = 508;
	public static final int OP_TO_CHIEF	= 509;
	
	//cotask suspend state
	public static final boolean SUPENDED   = true;
	public static final boolean UNSUPENDED = false;
	
	// new Cotask Action
	public static final int ACTION_SEND_OUT    = 1; //出库时产生状态为1的cotask
	public static final int ACTION_RECEIVE_IN  = 2; //入库时产生状态为2的cotask
	public static final int ACTION_FEEDBACK    = 3; //完工反馈时产生状态为2或者3的cotask
	
	//new cotask auto state
	public static final int CONSULT_ARITIFICIAL = 0;
	public static final int CONSULT_AUTO = 1;
	
	
	@Id
	@GenericGenerator(name = "uniqueId", strategy = "assigned")
	@Column(name = "COTASKUID")
	protected String uniqueId;
	
	// 任务编号，送出工序编号
	@Column(name = "TASKUID")
	private String taskUid;
	
	// 协作车间意见
	@Column(name = "COFEEDBACK")
	private String coFeedback;
	
	// 请制部门编号
	@Column(name = "DEPTID")
	private String deptUid;
	
	// 主制部门编号
	@Column(name = "MASTERSHOP")
	private String masterShopUid;
	
	// 协作计划员
	@Column(name = "PLANNER")
	private String plannerUid;
	
	// 协作计划时间
	@Column(name = "PLANTIME")
	private Date planTime;
	
	// 协作任务状态
	@Column(name = "COTASKSTATE")
	private Long cotaskState;
	
	// 
	@Column(name = "PART_NUMBER")
	private String partUid;
	
	// 
	@Column(name = "OPUID")
	private String operationUid;
	
	// 
	@Column(name = "AGREESTATE")
	private Long agreeState;
	
	// 
	@Column(name = "PRIORITY")
	private Long priority;
	
	// 
	@Column(name = "SUSPENDED")
	private Long suspended;
	
	// 创建人
	@Column(name = "BATCHNUM")
	private String batchNum;
	
	// 创建人
	@Column(name = "SCHEDULESTART")
	private Date scheduleStart;
	
	// 创建人
	@Column(name = "SCHEDULEFINISH")
	private Date scheduleFinish;
	
	// 创建人
	@Column(name = "COMPLETEQTY")
	private Long completeQty;
	
	// 创建人
	@Column(name = "ACTUALSTART")
	private Date actualStart;
	
	// 创建人
	@Column(name = "ACTUALFINISH")
	private Date actualFinish;
	
	// 创建人
	@Column(name = "PLANQTY")
	private Long planQty;
	
	// 计划送出日期
	@Column(name = "PLANSTART")
	private Date planStart;
	
	// 要求反回日期
	@Column(name = "PLANFINISH")
	private Date planFinish;
	
	// 工序号
	@Column(name = "OPERATION_IDDESC")
	private String operationIdDesc;
	
	// 创建人
	@Column(name = "TASKNAME")
	private String taskName;
	
	// 送出人
	@Column(name = "SENDER")
	private String senderUid;
	
	// 接收人
	@Column(name = "RECEIVER")
	private String receiverUid;
	
	// 取回人
	@Column(name = "FETCHER")
	private String fetcherUid;
	
	// 确认人
	@Column(name = "ACCEPTER")
	private String accepterUid;
	
	// 送出数量
	@Column(name = "SENDQTY")
	private Double sendQty;
	
	// 收到数量
	@Column(name = "RECEIVEQTY")
	private Double receiveQty;
	
	// 取回数量
	@Column(name = "FETCHQTY")
	private Double fetchQty;
	
	// 接收数量
	@Column(name = "ACCEPTQTY")
	private Double acceptQty;
	
	// 实际送出
	@Column(name = "ACTUALSEND")
	private Date actualSend;
	
	// 实际返回
	@Column(name = "ACTUALACCEPT")
	private Date actualAccept;
	
	// 实际接收
	@Column(name = "ACTUALRECEIVE")
	private Date actualReceive;
	
	// 实际取回
	@Column(name = "ACTUALFETCH")
	private Date actualFetch;
	
	// 创建人
	@Column(name = "SENDWAREHOUSEID")
	private String sendWarehouseUid;
	
	// 创建人
	@Column(name = "RECEIVEWAREHOUSEID")
	private String receiveWarehouseUid;
	
	// 创建人
	@Column(name = "FETCHWAREHOUSEID")
	private String fetchWarehouseUid;
	
	// 创建人
	@Column(name = "ACCEPTWAREHOUSEID")
	private String acceptWarehouseUid;
	
	// 型号
	@Column(name = "MODEL")
	private String model;
	
	// 报废数
	@Column(name = "EXPIRENUM")
	private Long expireQty;
	
	// 丢失数
	@Column(name = "LOSTNUM")
	private Long lostQty;
	
	// 零件任务Uid
	@Column(name = "PARENTUID")
	private String partTaskUid;
	
	// 工期
	@Column(name = "ESTIDURATION")
	private Long estiDuration;
	
	// 协调次数
	@Column(name = "CONSULT_COUNT")
	private Long consultCount;
	
	// 有暂停的提示信息
	@Column(name = "SUSPENDED_TIP")
	private Long suspendedTip;
	
	// 是否执行了自动协调。0未协调，1协调过
	@Column(name = "AUTOSTATE")
	private Integer autoState;
	
	private Set<Task> taskSet = new HashSet<Task>();

	public Cotask() {
	}

	public Cotask(String uniqueId, String taskuid) {
		this.uniqueId = uniqueId;
		this.taskUid = taskuid;
	}

	public String getUniqueId() {
		return uniqueId;
	}

	public void setUniqueId(String uniqueId) {
		this.uniqueId = uniqueId;
	}

	public String getTaskUid() {
		return taskUid;
	}

	public void setTaskUid(String taskUid) {
		this.taskUid = taskUid;
	}

	public String getCoFeedback() {
		return coFeedback;
	}

	public void setCoFeedback(String coFeedback) {
		this.coFeedback = coFeedback;
	}

	public String getDeptUid() {
		return deptUid;
	}

	public void setDeptUid(String deptUid) {
		this.deptUid = deptUid;
	}

	public String getMasterShopUid() {
		return masterShopUid;
	}

	public void setMasterShopUid(String masterShopUid) {
		this.masterShopUid = masterShopUid;
	}

	public String getCreatorUid() {
		return creatorUid;
	}

	public void setCreatorUid(String creatorUid) {
		this.creatorUid = creatorUid;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getPlannerUid() {
		return plannerUid;
	}

	public void setPlannerUid(String plannerUid) {
		this.plannerUid = plannerUid;
	}

	public Date getPlanTime() {
		return planTime;
	}

	public void setPlanTime(Date planTime) {
		this.planTime = planTime;
	}

	public Long getCotaskState() {
		return cotaskState;
	}

	public void setCotaskState(Long cotaskState) {
		this.cotaskState = cotaskState;
	}

	public String getPartUid() {
		return partUid;
	}

	public void setPartUid(String partUid) {
		this.partUid = partUid;
	}

	public String getOperationUid() {
		return operationUid;
	}

	public void setOperationUid(String operationUid) {
		this.operationUid = operationUid;
	}

	public Long getAgreeState() {
		return agreeState;
	}

	public void setAgreeState(Long agreeState) {
		this.agreeState = agreeState;
	}

	public Long getPriority() {
		return priority;
	}

	public void setPriority(Long priority) {
		this.priority = priority;
	}

	public Long getSuspended() {
		return suspended;
	}

	public void setSuspended(Long suspended) {
		this.suspended = suspended;
	}

	public String getBatchNum() {
		return batchNum;
	}

	public void setBatchNum(String batchNum) {
		this.batchNum = batchNum;
	}

	public Date getScheduleStart() {
		return scheduleStart;
	}

	public void setScheduleStart(Date scheduleStart) {
		this.scheduleStart = scheduleStart;
	}

	public Date getScheduleFinish() {
		return scheduleFinish;
	}

	public void setScheduleFinish(Date scheduleFinish) {
		this.scheduleFinish = scheduleFinish;
	}

	public Long getCompleteQty() {
		return completeQty;
	}

	public void setCompleteQty(Long completeQty) {
		this.completeQty = completeQty;
	}

	public Date getActualStart() {
		return actualStart;
	}

	public void setActualStart(Date actualStart) {
		this.actualStart = actualStart;
	}

	public Date getActualFinish() {
		return actualFinish;
	}

	public void setActualFinish(Date actualFinish) {
		this.actualFinish = actualFinish;
	}

	public Long getPlanQty() {
		return planQty;
	}

	public void setPlanQty(Long planQty) {
		this.planQty = planQty;
	}

	public Date getPlanStart() {
		return planStart;
	}

	public void setPlanStart(Date planStart) {
		this.planStart = planStart;
	}

	public Date getPlanFinish() {
		return planFinish;
	}

	public void setPlanFinish(Date planFinish) {
		this.planFinish = planFinish;
	}

	public String getOperationIdDesc() {
		return operationIdDesc;
	}

	public void setOperationIdDesc(String operationIdDesc) {
		this.operationIdDesc = operationIdDesc;
	}

	public String getTaskName() {
		return taskName;
	}

	public void setTaskName(String taskName) {
		this.taskName = taskName;
	}

	public String getSenderUid() {
		return senderUid;
	}

	public void setSenderUid(String senderUid) {
		this.senderUid = senderUid;
	}

	public String getReceiverUid() {
		return receiverUid;
	}

	public void setReceiverUid(String receiverUid) {
		this.receiverUid = receiverUid;
	}

	public String getFetcherUid() {
		return fetcherUid;
	}

	public void setFetcherUid(String fetcherUid) {
		this.fetcherUid = fetcherUid;
	}

	public String getAccepterUid() {
		return accepterUid;
	}

	public void setAccepterUid(String accepterUid) {
		this.accepterUid = accepterUid;
	}

	public String getNotes() {
		return notes;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}

	public Double getSendQty() {
		return sendQty;
	}

	public void setSendQty(Double sendQty) {
		this.sendQty = sendQty;
	}

	public Double getReceiveQty() {
		return receiveQty;
	}

	public void setReceiveQty(Double receiveQty) {
		this.receiveQty = receiveQty;
	}

	public Double getFetchQty() {
		return fetchQty;
	}

	public void setFetchQty(Double fetchQty) {
		this.fetchQty = fetchQty;
	}

	public Double getAcceptQty() {
		return acceptQty;
	}

	public void setAcceptQty(Double acceptQty) {
		this.acceptQty = acceptQty;
	}

	public Date getActualSend() {
		return actualSend;
	}

	public void setActualSend(Date actualSend) {
		this.actualSend = actualSend;
	}

	public Date getActualAccept() {
		return actualAccept;
	}

	public void setActualAccept(Date actualAccept) {
		this.actualAccept = actualAccept;
	}

	public Date getActualReceive() {
		return actualReceive;
	}

	public void setActualReceive(Date actualReceive) {
		this.actualReceive = actualReceive;
	}

	public Date getActualFetch() {
		return actualFetch;
	}

	public void setActualFetch(Date actualFetch) {
		this.actualFetch = actualFetch;
	}

	public String getSendWarehouseUid() {
		return sendWarehouseUid;
	}

	public void setSendWarehouseUid(String sendWarehouseUid) {
		this.sendWarehouseUid = sendWarehouseUid;
	}

	public String getReceiveWarehouseUid() {
		return receiveWarehouseUid;
	}

	public void setReceiveWarehouseUid(String receiveWarehouseUid) {
		this.receiveWarehouseUid = receiveWarehouseUid;
	}

	public String getFetchWarehouseUid() {
		return fetchWarehouseUid;
	}

	public void setFetchWarehouseUid(String fetchWarehouseUid) {
		this.fetchWarehouseUid = fetchWarehouseUid;
	}

	public String getAcceptWarehouseUid() {
		return acceptWarehouseUid;
	}

	public void setAcceptWarehouseUid(String acceptWarehouseUid) {
		this.acceptWarehouseUid = acceptWarehouseUid;
	}

	public String getModel() {
		return model;
	}

	public void setModel(String model) {
		this.model = model;
	}

	public Long getExpireQty() {
		return expireQty;
	}

	public void setExpireQty(Long expireQty) {
		this.expireQty = expireQty;
	}

	public Long getLostQty() {
		return lostQty;
	}

	public void setLostQty(Long lostQty) {
		this.lostQty = lostQty;
	}

	public String getPartTaskUid() {
		return partTaskUid;
	}

	public void setPartTaskUid(String partTaskUid) {
		this.partTaskUid = partTaskUid;
	}

	public Long getEstiDuration() {
		return estiDuration;
	}

	public void setEstiDuration(Long estiDuration) {
		this.estiDuration = estiDuration;
	}

	public Long getConsultCount() {
		return consultCount;
	}

	public void setConsultCount(Long consultCount) {
		this.consultCount = consultCount;
	}

	public Long getSuspendedTip() {
		return suspendedTip;
	}

	public void setSuspendedTip(Long suspendedTip) {
		this.suspendedTip = suspendedTip;
	}

	public Set<Task> getTaskSet() {
		return taskSet;
	}

	public void setTaskSet(Set<Task> taskSet) {
		this.taskSet = taskSet;
	}

	@Override
	public String getUuid() {
		// TODO Auto-generated method stub
		return this.getUniqueId();
	}

	@Override
	public void setUuid(String uuid) {
		// TODO Auto-generated method stub
		this.setUniqueId(uuid);;
	}

	public Integer getAutoState() {
		return autoState;
	}

	public void setAutoState(Integer autoState) {
		this.autoState = autoState;
	}
	
}